﻿
var pointerManager = function () {
    this.pointers = {};
    this.register = function (pointer) {
        if (pointer.id() == null) {
            pointer.id(Utils.getGuid());
        }
        this.pointers[pointer.id()] = pointer;
        return pointer.id();
    };
    this.get = function (name) {
        if (name == null || name == "") return false;
        for (var pointer in this.pointers) {
            if (pointer == name) {
                return this.pointers[pointer];
            }
        }
        return false;
    };
    this.remove = function (name) {
        if (this.pointers[name]) {
            delete this.pointers[name];
        }
    };
    this.exists = function (name) {
        if (name == null) return false;
        for (var pointer in this.pointers) {
            if (pointer == name) {
                return true;
            }
        }
        return false;
    };
    this.getIdByEvent = function (event) {
        var jo = $(event.target);
        var o = jo.closest("pointerid");
        if (o.size() > 0) {
            return o.attr("pointerid");
        }
        return mWindowpointer.pointerid;
    };
};

var mPointerManager = new pointerManager();
if (top != self) {
    mPointerManager = top.mPointerManager;
}